// $ANTLR 3.4 C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g 2012-02-05 21:12:53

	package script.grammar;
	
	import script.grammar.symbol.*;


import org.antlr.runtime.*;
import org.antlr.runtime.tree.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;

@SuppressWarnings({"all", "warnings", "unchecked"})
public class LocScriptCheckPass extends TreeFilter {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "AND", "ARRAY_ACCESS", "ASSIGN", "BIT_AND", "BIT_NEG", "BIT_OR", "BLOCK", "CLOSE_BRACE", "CLOSE_BRACK", "CLOSE_PARENS", "COND_OP", "DEF", "DIV", "DIV_ASSIGN", "EQUALS", "EXPR", "FALSE", "FILTER", "FLOAT", "FOR", "GREATER_THAN", "GREATER_THAN_EQUALS", "ID", "INT", "LESS_THAN", "LESS_THAN_EQUALS", "MEM_ACCESS", "MINUS", "MINUS_ASSIGN", "MOD", "MULT", "MULT_ASSIGN", "NEG", "NOT", "NOT_EQUALS", "OPEN_BRACE", "OPEN_BRACK", "OPEN_PARENS", "OR", "PLUS", "PLUS_ASSIGN", "POST_DEC", "POST_INC", "PRE_DEC", "PRE_INC", "RETURN", "SHIFT_LEFT", "SHIFT_RIGHT", "THIS", "TRUE", "U_SHIFT_RIGHT", "VAR", "WS", "XOR", "'++'", "','", "'--'", "':'", "';'", "'?'"
    };

    public static final int EOF=-1;
    public static final int T__58=58;
    public static final int T__59=59;
    public static final int T__60=60;
    public static final int T__61=61;
    public static final int T__62=62;
    public static final int T__63=63;
    public static final int AND=4;
    public static final int ARRAY_ACCESS=5;
    public static final int ASSIGN=6;
    public static final int BIT_AND=7;
    public static final int BIT_NEG=8;
    public static final int BIT_OR=9;
    public static final int BLOCK=10;
    public static final int CLOSE_BRACE=11;
    public static final int CLOSE_BRACK=12;
    public static final int CLOSE_PARENS=13;
    public static final int COND_OP=14;
    public static final int DEF=15;
    public static final int DIV=16;
    public static final int DIV_ASSIGN=17;
    public static final int EQUALS=18;
    public static final int EXPR=19;
    public static final int FALSE=20;
    public static final int FILTER=21;
    public static final int FLOAT=22;
    public static final int FOR=23;
    public static final int GREATER_THAN=24;
    public static final int GREATER_THAN_EQUALS=25;
    public static final int ID=26;
    public static final int INT=27;
    public static final int LESS_THAN=28;
    public static final int LESS_THAN_EQUALS=29;
    public static final int MEM_ACCESS=30;
    public static final int MINUS=31;
    public static final int MINUS_ASSIGN=32;
    public static final int MOD=33;
    public static final int MULT=34;
    public static final int MULT_ASSIGN=35;
    public static final int NEG=36;
    public static final int NOT=37;
    public static final int NOT_EQUALS=38;
    public static final int OPEN_BRACE=39;
    public static final int OPEN_BRACK=40;
    public static final int OPEN_PARENS=41;
    public static final int OR=42;
    public static final int PLUS=43;
    public static final int PLUS_ASSIGN=44;
    public static final int POST_DEC=45;
    public static final int POST_INC=46;
    public static final int PRE_DEC=47;
    public static final int PRE_INC=48;
    public static final int RETURN=49;
    public static final int SHIFT_LEFT=50;
    public static final int SHIFT_RIGHT=51;
    public static final int THIS=52;
    public static final int TRUE=53;
    public static final int U_SHIFT_RIGHT=54;
    public static final int VAR=55;
    public static final int WS=56;
    public static final int XOR=57;

    // delegates
    public TreeFilter[] getDelegates() {
        return new TreeFilter[] {};
    }

    // delegators


    public LocScriptCheckPass(TreeNodeStream input) {
        this(input, new RecognizerSharedState());
    }
    public LocScriptCheckPass(TreeNodeStream input, RecognizerSharedState state) {
        super(input, state);
    }

    public String[] getTokenNames() { return LocScriptCheckPass.tokenNames; }
    public String getGrammarFileName() { return "C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g"; }


    	SymbolTable symbolTable;
    	Scope currentScope;
    	
    	public LocScriptCheckPass(TreeNodeStream in, SymbolTable symbolTable) {
    		this(in);
    		this.symbolTable = symbolTable;
    		currentScope = symbolTable.getLocalScope();
    	}



    // $ANTLR start "topdown"
    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:26:1: topdown : ( enterFor | enterBlock | atoms );
    public final void topdown() throws RecognitionException {
        try {
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:27:2: ( enterFor | enterBlock | atoms )
            int alt1=3;
            switch ( input.LA(1) ) {
            case FOR:
                {
                alt1=1;
                }
                break;
            case BLOCK:
                {
                alt1=2;
                }
                break;
            case ID:
                {
                alt1=3;
                }
                break;
            default:
                if (state.backtracking>0) {state.failed=true; return ;}
                NoViableAltException nvae =
                    new NoViableAltException("", 1, 0, input);

                throw nvae;

            }

            switch (alt1) {
                case 1 :
                    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:27:4: enterFor
                    {
                    pushFollow(FOLLOW_enterFor_in_topdown54);
                    enterFor();

                    state._fsp--;
                    if (state.failed) return ;

                    }
                    break;
                case 2 :
                    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:28:4: enterBlock
                    {
                    pushFollow(FOLLOW_enterBlock_in_topdown59);
                    enterBlock();

                    state._fsp--;
                    if (state.failed) return ;

                    }
                    break;
                case 3 :
                    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:29:4: atoms
                    {
                    pushFollow(FOLLOW_atoms_in_topdown64);
                    atoms();

                    state._fsp--;
                    if (state.failed) return ;

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return ;
    }
    // $ANTLR end "topdown"



    // $ANTLR start "bottomup"
    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:32:1: bottomup : ( exitBlock | exprRoot | returnStat | def | foreach );
    public final void bottomup() throws RecognitionException {
        try {
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:33:2: ( exitBlock | exprRoot | returnStat | def | foreach )
            int alt2=5;
            switch ( input.LA(1) ) {
            case BLOCK:
                {
                alt2=1;
                }
                break;
            case EXPR:
                {
                alt2=2;
                }
                break;
            case RETURN:
                {
                alt2=3;
                }
                break;
            case DEF:
                {
                alt2=4;
                }
                break;
            case FOR:
                {
                alt2=5;
                }
                break;
            default:
                if (state.backtracking>0) {state.failed=true; return ;}
                NoViableAltException nvae =
                    new NoViableAltException("", 2, 0, input);

                throw nvae;

            }

            switch (alt2) {
                case 1 :
                    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:33:4: exitBlock
                    {
                    pushFollow(FOLLOW_exitBlock_in_bottomup75);
                    exitBlock();

                    state._fsp--;
                    if (state.failed) return ;

                    }
                    break;
                case 2 :
                    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:34:4: exprRoot
                    {
                    pushFollow(FOLLOW_exprRoot_in_bottomup80);
                    exprRoot();

                    state._fsp--;
                    if (state.failed) return ;

                    }
                    break;
                case 3 :
                    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:35:4: returnStat
                    {
                    pushFollow(FOLLOW_returnStat_in_bottomup85);
                    returnStat();

                    state._fsp--;
                    if (state.failed) return ;

                    }
                    break;
                case 4 :
                    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:36:4: def
                    {
                    pushFollow(FOLLOW_def_in_bottomup90);
                    def();

                    state._fsp--;
                    if (state.failed) return ;

                    }
                    break;
                case 5 :
                    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:37:4: foreach
                    {
                    pushFollow(FOLLOW_foreach_in_bottomup95);
                    foreach();

                    state._fsp--;
                    if (state.failed) return ;

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return ;
    }
    // $ANTLR end "bottomup"



    // $ANTLR start "enterFor"
    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:40:1: enterFor : FOR ;
    public final void enterFor() throws RecognitionException {
        try {
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:41:2: ( FOR )
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:41:4: FOR
            {
            match(input,FOR,FOLLOW_FOR_in_enterFor107); if (state.failed) return ;

            if ( state.backtracking==1 ) {currentScope = new BaseScope("Foreach Scope", currentScope);}

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return ;
    }
    // $ANTLR end "enterFor"



    // $ANTLR start "enterBlock"
    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:44:1: enterBlock : BLOCK ;
    public final void enterBlock() throws RecognitionException {
        try {
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:45:2: ( BLOCK )
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:45:4: BLOCK
            {
            match(input,BLOCK,FOLLOW_BLOCK_in_enterBlock121); if (state.failed) return ;

            if ( state.backtracking==1 ) {currentScope = new BaseScope("Block Scope", currentScope);}

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return ;
    }
    // $ANTLR end "enterBlock"



    // $ANTLR start "exitBlock"
    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:48:1: exitBlock : BLOCK ;
    public final void exitBlock() throws RecognitionException {
        try {
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:49:2: ( BLOCK )
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:49:4: BLOCK
            {
            match(input,BLOCK,FOLLOW_BLOCK_in_exitBlock135); if (state.failed) return ;

            if ( state.backtracking==1 ) {currentScope = currentScope.getEnclosingScope();}

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return ;
    }
    // $ANTLR end "exitBlock"



    // $ANTLR start "atoms"
    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:52:1: atoms :{...}? ID ;
    public final void atoms() throws RecognitionException {
        LocScriptAST t = (LocScriptAST)input.LT(1);
        try {
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:54:5: ({...}? ID )
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:54:8: {...}? ID
            {
            if ( !((t.hasAncestor(EXPR)||t.hasAncestor(DEF))) ) {
                if (state.backtracking>0) {state.failed=true; return ;}
                throw new FailedPredicateException(input, "atoms", "t.hasAncestor(EXPR)||t.hasAncestor(DEF)");
            }

            match(input,ID,FOLLOW_ID_in_atoms160); if (state.failed) return ;

            if ( state.backtracking==1 ) {t.scope = currentScope;}

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return ;
    }
    // $ANTLR end "atoms"



    // $ANTLR start "foreach"
    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:58:1: foreach : ^( FOR v= . e= . . ) ;
    public final void foreach() throws RecognitionException {
        LocScriptAST v=null;
        LocScriptAST e=null;

        try {
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:59:2: ( ^( FOR v= . e= . . ) )
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:59:4: ^( FOR v= . e= . . )
            {
            match(input,FOR,FOLLOW_FOR_in_foreach185); if (state.failed) return ;

            match(input, Token.DOWN, null); if (state.failed) return ;
            v=(LocScriptAST)input.LT(1);

            matchAny(input); if (state.failed) return ;

            e=(LocScriptAST)input.LT(1);

            matchAny(input); if (state.failed) return ;

            matchAny(input); if (state.failed) return ;

            match(input, Token.UP, null); if (state.failed) return ;


            if ( state.backtracking==1 ) {currentScope = currentScope.getEnclosingScope(); symbolTable.handleForEach(v, e);}

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return ;
    }
    // $ANTLR end "foreach"



    // $ANTLR start "returnStat"
    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:62:1: returnStat : ^( RETURN a= . ) ;
    public final void returnStat() throws RecognitionException {
        LocScriptAST a=null;

        try {
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:63:2: ( ^( RETURN a= . ) )
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:63:4: ^( RETURN a= . )
            {
            match(input,RETURN,FOLLOW_RETURN_in_returnStat211); if (state.failed) return ;

            match(input, Token.DOWN, null); if (state.failed) return ;
            a=(LocScriptAST)input.LT(1);

            matchAny(input); if (state.failed) return ;

            match(input, Token.UP, null); if (state.failed) return ;


            if ( state.backtracking==1 ) {symbolTable.handleReturn(a);}

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return ;
    }
    // $ANTLR end "returnStat"



    // $ANTLR start "def"
    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:66:1: def : ^( DEF a= ID b= ID ( exprRoot )? ) ;
    public final void def() throws RecognitionException {
        LocScriptAST a=null;
        LocScriptAST b=null;
        LocScriptCheckPass.exprRoot_return exprRoot1 =null;


        LocScriptAST init = null;
        try {
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:68:2: ( ^( DEF a= ID b= ID ( exprRoot )? ) )
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:68:4: ^( DEF a= ID b= ID ( exprRoot )? )
            {
            match(input,DEF,FOLLOW_DEF_in_def236); if (state.failed) return ;

            match(input, Token.DOWN, null); if (state.failed) return ;
            a=(LocScriptAST)match(input,ID,FOLLOW_ID_in_def240); if (state.failed) return ;

            b=(LocScriptAST)match(input,ID,FOLLOW_ID_in_def244); if (state.failed) return ;

            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:68:20: ( exprRoot )?
            int alt3=2;
            int LA3_0 = input.LA(1);

            if ( (LA3_0==EXPR) ) {
                alt3=1;
            }
            switch (alt3) {
                case 1 :
                    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:68:21: exprRoot
                    {
                    pushFollow(FOLLOW_exprRoot_in_def247);
                    exprRoot1=exprRoot();

                    state._fsp--;
                    if (state.failed) return ;

                    if ( state.backtracking==1 ) {init=(exprRoot1!=null?((LocScriptAST)exprRoot1.start):null);}

                    }
                    break;

            }


            match(input, Token.UP, null); if (state.failed) return ;


            if ( state.backtracking==1 ) {symbolTable.defineVariable(a, b, init);}

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return ;
    }
    // $ANTLR end "def"


    public static class exprRoot_return extends TreeRuleReturnScope {
    };


    // $ANTLR start "exprRoot"
    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:71:1: exprRoot : ^( EXPR expr ) ;
    public final LocScriptCheckPass.exprRoot_return exprRoot() throws RecognitionException {
        LocScriptCheckPass.exprRoot_return retval = new LocScriptCheckPass.exprRoot_return();
        retval.start = input.LT(1);


        LocScriptAST EXPR2=null;
        LocScriptCheckPass.expr_return expr3 =null;


        try {
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:72:2: ( ^( EXPR expr ) )
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:72:4: ^( EXPR expr )
            {
            EXPR2=(LocScriptAST)match(input,EXPR,FOLLOW_EXPR_in_exprRoot268); if (state.failed) return retval;

            match(input, Token.DOWN, null); if (state.failed) return retval;
            pushFollow(FOLLOW_expr_in_exprRoot270);
            expr3=expr();

            state._fsp--;
            if (state.failed) return retval;

            match(input, Token.UP, null); if (state.failed) return retval;


            if ( state.backtracking==1 ) {EXPR2.evalType = (expr3!=null?expr3.type:null);}

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return retval;
    }
    // $ANTLR end "exprRoot"


    public static class expr_return extends TreeRuleReturnScope {
        public Type type;
    };


    // $ANTLR start "expr"
    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:75:1: expr returns [Type type] : ( ( TRUE | FALSE ) | INT | FLOAT | ^( VAR ID ) | member | unaryOp | binaryOp | ternaryOp | arrayAccess );
    public final LocScriptCheckPass.expr_return expr() throws RecognitionException {
        LocScriptCheckPass.expr_return retval = new LocScriptCheckPass.expr_return();
        retval.start = input.LT(1);


        LocScriptAST ID4=null;
        Type member5 =null;

        Type unaryOp6 =null;

        Type binaryOp7 =null;

        Type ternaryOp8 =null;

        Type arrayAccess9 =null;


        try {
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:77:2: ( ( TRUE | FALSE ) | INT | FLOAT | ^( VAR ID ) | member | unaryOp | binaryOp | ternaryOp | arrayAccess )
            int alt4=9;
            switch ( input.LA(1) ) {
            case FALSE:
            case TRUE:
                {
                alt4=1;
                }
                break;
            case INT:
                {
                alt4=2;
                }
                break;
            case FLOAT:
                {
                alt4=3;
                }
                break;
            case VAR:
                {
                alt4=4;
                }
                break;
            case MEM_ACCESS:
                {
                alt4=5;
                }
                break;
            case BIT_NEG:
            case NEG:
            case NOT:
            case POST_DEC:
            case POST_INC:
            case PRE_DEC:
            case PRE_INC:
                {
                alt4=6;
                }
                break;
            case AND:
            case ASSIGN:
            case BIT_AND:
            case BIT_OR:
            case DIV:
            case DIV_ASSIGN:
            case EQUALS:
            case GREATER_THAN:
            case GREATER_THAN_EQUALS:
            case LESS_THAN:
            case LESS_THAN_EQUALS:
            case MINUS:
            case MINUS_ASSIGN:
            case MOD:
            case MULT:
            case MULT_ASSIGN:
            case NOT_EQUALS:
            case OR:
            case PLUS:
            case PLUS_ASSIGN:
            case SHIFT_LEFT:
            case SHIFT_RIGHT:
            case U_SHIFT_RIGHT:
            case XOR:
                {
                alt4=7;
                }
                break;
            case COND_OP:
                {
                alt4=8;
                }
                break;
            case ARRAY_ACCESS:
                {
                alt4=9;
                }
                break;
            default:
                if (state.backtracking>0) {state.failed=true; return retval;}
                NoViableAltException nvae =
                    new NoViableAltException("", 4, 0, input);

                throw nvae;

            }

            switch (alt4) {
                case 1 :
                    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:77:4: ( TRUE | FALSE )
                    {
                    if ( input.LA(1)==FALSE||input.LA(1)==TRUE ) {
                        input.consume();
                        state.errorRecovery=false;
                        state.failed=false;
                    }
                    else {
                        if (state.backtracking>0) {state.failed=true; return retval;}
                        MismatchedSetException mse = new MismatchedSetException(null,input);
                        throw mse;
                    }


                    if ( state.backtracking==1 ) {retval.type =NativeType.BOOLEAN;}

                    }
                    break;
                case 2 :
                    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:78:4: INT
                    {
                    match(input,INT,FOLLOW_INT_in_expr305); if (state.failed) return retval;

                    if ( state.backtracking==1 ) {retval.type =NativeType.INT;}

                    }
                    break;
                case 3 :
                    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:79:4: FLOAT
                    {
                    match(input,FLOAT,FOLLOW_FLOAT_in_expr312); if (state.failed) return retval;

                    if ( state.backtracking==1 ) {retval.type =NativeType.DOUBLE;}

                    }
                    break;
                case 4 :
                    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:80:4: ^( VAR ID )
                    {
                    match(input,VAR,FOLLOW_VAR_in_expr320); if (state.failed) return retval;

                    match(input, Token.DOWN, null); if (state.failed) return retval;
                    ID4=(LocScriptAST)match(input,ID,FOLLOW_ID_in_expr322); if (state.failed) return retval;

                    match(input, Token.UP, null); if (state.failed) return retval;


                    if ( state.backtracking==1 ) {
                    		Symbol s = symbolTable.resolveVariable(ID4);
                    		retval.type = s.getType();
                    		}

                    }
                    break;
                case 5 :
                    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:85:4: member
                    {
                    pushFollow(FOLLOW_member_in_expr332);
                    member5=member();

                    state._fsp--;
                    if (state.failed) return retval;

                    if ( state.backtracking==1 ) {retval.type =member5;}

                    }
                    break;
                case 6 :
                    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:86:4: unaryOp
                    {
                    pushFollow(FOLLOW_unaryOp_in_expr339);
                    unaryOp6=unaryOp();

                    state._fsp--;
                    if (state.failed) return retval;

                    if ( state.backtracking==1 ) {retval.type =unaryOp6;}

                    }
                    break;
                case 7 :
                    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:87:4: binaryOp
                    {
                    pushFollow(FOLLOW_binaryOp_in_expr346);
                    binaryOp7=binaryOp();

                    state._fsp--;
                    if (state.failed) return retval;

                    if ( state.backtracking==1 ) {retval.type =binaryOp7;}

                    }
                    break;
                case 8 :
                    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:88:4: ternaryOp
                    {
                    pushFollow(FOLLOW_ternaryOp_in_expr353);
                    ternaryOp8=ternaryOp();

                    state._fsp--;
                    if (state.failed) return retval;

                    if ( state.backtracking==1 ) {retval.type =ternaryOp8;}

                    }
                    break;
                case 9 :
                    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:89:4: arrayAccess
                    {
                    pushFollow(FOLLOW_arrayAccess_in_expr360);
                    arrayAccess9=arrayAccess();

                    state._fsp--;
                    if (state.failed) return retval;

                    if ( state.backtracking==1 ) {retval.type =arrayAccess9;}

                    }
                    break;

            }
            if ( state.backtracking==1 ) {((LocScriptAST)retval.start).evalType=retval.type;}
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return retval;
    }
    // $ANTLR end "expr"



    // $ANTLR start "member"
    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:92:1: member returns [Type type] : ( ^( MEM_ACCESS THIS ID ) | ^( MEM_ACCESS expr ID ) );
    public final Type member() throws RecognitionException {
        Type type = null;


        LocScriptAST ID10=null;
        LocScriptAST ID12=null;
        LocScriptCheckPass.expr_return expr11 =null;


        try {
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:93:2: ( ^( MEM_ACCESS THIS ID ) | ^( MEM_ACCESS expr ID ) )
            int alt5=2;
            int LA5_0 = input.LA(1);

            if ( (LA5_0==MEM_ACCESS) ) {
                int LA5_1 = input.LA(2);

                if ( (LA5_1==DOWN) ) {
                    int LA5_2 = input.LA(3);

                    if ( (LA5_2==THIS) ) {
                        alt5=1;
                    }
                    else if ( ((LA5_2 >= AND && LA5_2 <= BIT_OR)||LA5_2==COND_OP||(LA5_2 >= DIV && LA5_2 <= EQUALS)||LA5_2==FALSE||LA5_2==FLOAT||(LA5_2 >= GREATER_THAN && LA5_2 <= GREATER_THAN_EQUALS)||(LA5_2 >= INT && LA5_2 <= NOT_EQUALS)||(LA5_2 >= OR && LA5_2 <= PRE_INC)||(LA5_2 >= SHIFT_LEFT && LA5_2 <= SHIFT_RIGHT)||(LA5_2 >= TRUE && LA5_2 <= VAR)||LA5_2==XOR) ) {
                        alt5=2;
                    }
                    else {
                        if (state.backtracking>0) {state.failed=true; return type;}
                        NoViableAltException nvae =
                            new NoViableAltException("", 5, 2, input);

                        throw nvae;

                    }
                }
                else {
                    if (state.backtracking>0) {state.failed=true; return type;}
                    NoViableAltException nvae =
                        new NoViableAltException("", 5, 1, input);

                    throw nvae;

                }
            }
            else {
                if (state.backtracking>0) {state.failed=true; return type;}
                NoViableAltException nvae =
                    new NoViableAltException("", 5, 0, input);

                throw nvae;

            }
            switch (alt5) {
                case 1 :
                    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:93:4: ^( MEM_ACCESS THIS ID )
                    {
                    match(input,MEM_ACCESS,FOLLOW_MEM_ACCESS_in_member379); if (state.failed) return type;

                    match(input, Token.DOWN, null); if (state.failed) return type;
                    match(input,THIS,FOLLOW_THIS_in_member381); if (state.failed) return type;

                    ID10=(LocScriptAST)match(input,ID,FOLLOW_ID_in_member383); if (state.failed) return type;

                    match(input, Token.UP, null); if (state.failed) return type;


                    if ( state.backtracking==1 ) {type = symbolTable.resolveMember(ID10).getType();}

                    }
                    break;
                case 2 :
                    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:95:4: ^( MEM_ACCESS expr ID )
                    {
                    match(input,MEM_ACCESS,FOLLOW_MEM_ACCESS_in_member395); if (state.failed) return type;

                    match(input, Token.DOWN, null); if (state.failed) return type;
                    pushFollow(FOLLOW_expr_in_member397);
                    expr11=expr();

                    state._fsp--;
                    if (state.failed) return type;

                    ID12=(LocScriptAST)match(input,ID,FOLLOW_ID_in_member399); if (state.failed) return type;

                    match(input, Token.UP, null); if (state.failed) return type;


                    if ( state.backtracking==1 ) {type = symbolTable.resolveMember((expr11!=null?((LocScriptAST)expr11.start):null), ID12).getType();}

                    }
                    break;

            }
        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return type;
    }
    // $ANTLR end "member"



    // $ANTLR start "unaryOp"
    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:99:1: unaryOp returns [Type type] : ^(o= ( NEG | BIT_NEG | NOT | PRE_INC | PRE_DEC | POST_INC | POST_DEC ) expr ) ;
    public final Type unaryOp() throws RecognitionException {
        Type type = null;


        LocScriptAST o=null;
        LocScriptCheckPass.expr_return expr13 =null;


        try {
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:100:2: ( ^(o= ( NEG | BIT_NEG | NOT | PRE_INC | PRE_DEC | POST_INC | POST_DEC ) expr ) )
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:100:4: ^(o= ( NEG | BIT_NEG | NOT | PRE_INC | PRE_DEC | POST_INC | POST_DEC ) expr )
            {
            o=(LocScriptAST)input.LT(1);

            if ( input.LA(1)==BIT_NEG||(input.LA(1) >= NEG && input.LA(1) <= NOT)||(input.LA(1) >= POST_DEC && input.LA(1) <= PRE_INC) ) {
                input.consume();
                state.errorRecovery=false;
                state.failed=false;
            }
            else {
                if (state.backtracking>0) {state.failed=true; return type;}
                MismatchedSetException mse = new MismatchedSetException(null,input);
                throw mse;
            }


            match(input, Token.DOWN, null); if (state.failed) return type;
            pushFollow(FOLLOW_expr_in_unaryOp440);
            expr13=expr();

            state._fsp--;
            if (state.failed) return type;

            match(input, Token.UP, null); if (state.failed) return type;


            if ( state.backtracking==1 ) {type =symbolTable.computeType(o, (expr13!=null?((LocScriptAST)expr13.start):null));}

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return type;
    }
    // $ANTLR end "unaryOp"



    // $ANTLR start "binaryOp"
    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:104:1: binaryOp returns [Type type] : ^(o= ( PLUS | MINUS | MULT | DIV | MOD | GREATER_THAN | LESS_THAN | GREATER_THAN_EQUALS | LESS_THAN_EQUALS | EQUALS | NOT_EQUALS | AND | OR | BIT_AND | BIT_OR | XOR | SHIFT_LEFT | SHIFT_RIGHT | U_SHIFT_RIGHT | ASSIGN | PLUS_ASSIGN | MINUS_ASSIGN | MULT_ASSIGN | DIV_ASSIGN ) a= expr b= expr ) ;
    public final Type binaryOp() throws RecognitionException {
        Type type = null;


        LocScriptAST o=null;
        LocScriptCheckPass.expr_return a =null;

        LocScriptCheckPass.expr_return b =null;


        try {
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:105:2: ( ^(o= ( PLUS | MINUS | MULT | DIV | MOD | GREATER_THAN | LESS_THAN | GREATER_THAN_EQUALS | LESS_THAN_EQUALS | EQUALS | NOT_EQUALS | AND | OR | BIT_AND | BIT_OR | XOR | SHIFT_LEFT | SHIFT_RIGHT | U_SHIFT_RIGHT | ASSIGN | PLUS_ASSIGN | MINUS_ASSIGN | MULT_ASSIGN | DIV_ASSIGN ) a= expr b= expr ) )
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:105:4: ^(o= ( PLUS | MINUS | MULT | DIV | MOD | GREATER_THAN | LESS_THAN | GREATER_THAN_EQUALS | LESS_THAN_EQUALS | EQUALS | NOT_EQUALS | AND | OR | BIT_AND | BIT_OR | XOR | SHIFT_LEFT | SHIFT_RIGHT | U_SHIFT_RIGHT | ASSIGN | PLUS_ASSIGN | MINUS_ASSIGN | MULT_ASSIGN | DIV_ASSIGN ) a= expr b= expr )
            {
            o=(LocScriptAST)input.LT(1);

            if ( input.LA(1)==AND||(input.LA(1) >= ASSIGN && input.LA(1) <= BIT_AND)||input.LA(1)==BIT_OR||(input.LA(1) >= DIV && input.LA(1) <= EQUALS)||(input.LA(1) >= GREATER_THAN && input.LA(1) <= GREATER_THAN_EQUALS)||(input.LA(1) >= LESS_THAN && input.LA(1) <= LESS_THAN_EQUALS)||(input.LA(1) >= MINUS && input.LA(1) <= MULT_ASSIGN)||input.LA(1)==NOT_EQUALS||(input.LA(1) >= OR && input.LA(1) <= PLUS_ASSIGN)||(input.LA(1) >= SHIFT_LEFT && input.LA(1) <= SHIFT_RIGHT)||input.LA(1)==U_SHIFT_RIGHT||input.LA(1)==XOR ) {
                input.consume();
                state.errorRecovery=false;
                state.failed=false;
            }
            else {
                if (state.backtracking>0) {state.failed=true; return type;}
                MismatchedSetException mse = new MismatchedSetException(null,input);
                throw mse;
            }


            match(input, Token.DOWN, null); if (state.failed) return type;
            pushFollow(FOLLOW_expr_in_binaryOp544);
            a=expr();

            state._fsp--;
            if (state.failed) return type;

            pushFollow(FOLLOW_expr_in_binaryOp548);
            b=expr();

            state._fsp--;
            if (state.failed) return type;

            match(input, Token.UP, null); if (state.failed) return type;


            if ( state.backtracking==1 ) {type =symbolTable.computeType(o, (a!=null?((LocScriptAST)a.start):null), (b!=null?((LocScriptAST)b.start):null));}

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return type;
    }
    // $ANTLR end "binaryOp"



    // $ANTLR start "ternaryOp"
    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:116:1: ternaryOp returns [Type type] : ^( COND_OP a= expr b= expr c= expr ) ;
    public final Type ternaryOp() throws RecognitionException {
        Type type = null;


        LocScriptAST COND_OP14=null;
        LocScriptCheckPass.expr_return a =null;

        LocScriptCheckPass.expr_return b =null;

        LocScriptCheckPass.expr_return c =null;


        try {
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:117:2: ( ^( COND_OP a= expr b= expr c= expr ) )
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:117:4: ^( COND_OP a= expr b= expr c= expr )
            {
            COND_OP14=(LocScriptAST)match(input,COND_OP,FOLLOW_COND_OP_in_ternaryOp570); if (state.failed) return type;

            match(input, Token.DOWN, null); if (state.failed) return type;
            pushFollow(FOLLOW_expr_in_ternaryOp574);
            a=expr();

            state._fsp--;
            if (state.failed) return type;

            pushFollow(FOLLOW_expr_in_ternaryOp578);
            b=expr();

            state._fsp--;
            if (state.failed) return type;

            pushFollow(FOLLOW_expr_in_ternaryOp582);
            c=expr();

            state._fsp--;
            if (state.failed) return type;

            match(input, Token.UP, null); if (state.failed) return type;


            if ( state.backtracking==1 ) {type =symbolTable.computeType(COND_OP14, (a!=null?((LocScriptAST)a.start):null), (b!=null?((LocScriptAST)b.start):null), (c!=null?((LocScriptAST)c.start):null));}

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return type;
    }
    // $ANTLR end "ternaryOp"



    // $ANTLR start "arrayAccess"
    // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:120:1: arrayAccess returns [Type type] : ^( ARRAY_ACCESS a= expr b= expr ) ;
    public final Type arrayAccess() throws RecognitionException {
        Type type = null;


        LocScriptCheckPass.expr_return a =null;

        LocScriptCheckPass.expr_return b =null;


        try {
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:121:2: ( ^( ARRAY_ACCESS a= expr b= expr ) )
            // C:\\Users\\Charles\\Documents\\ANTLR\\LocalizationScript\\LocScriptCheckPass.g:121:4: ^( ARRAY_ACCESS a= expr b= expr )
            {
            match(input,ARRAY_ACCESS,FOLLOW_ARRAY_ACCESS_in_arrayAccess602); if (state.failed) return type;

            match(input, Token.DOWN, null); if (state.failed) return type;
            pushFollow(FOLLOW_expr_in_arrayAccess606);
            a=expr();

            state._fsp--;
            if (state.failed) return type;

            pushFollow(FOLLOW_expr_in_arrayAccess610);
            b=expr();

            state._fsp--;
            if (state.failed) return type;

            match(input, Token.UP, null); if (state.failed) return type;


            if ( state.backtracking==1 ) {type =symbolTable.handleArrayAccess((a!=null?((LocScriptAST)a.start):null), (b!=null?((LocScriptAST)b.start):null));}

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return type;
    }
    // $ANTLR end "arrayAccess"

    // Delegated rules


 

    public static final BitSet FOLLOW_enterFor_in_topdown54 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_enterBlock_in_topdown59 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_atoms_in_topdown64 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_exitBlock_in_bottomup75 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_exprRoot_in_bottomup80 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_returnStat_in_bottomup85 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_def_in_bottomup90 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_foreach_in_bottomup95 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_FOR_in_enterFor107 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_BLOCK_in_enterBlock121 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_BLOCK_in_exitBlock135 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ID_in_atoms160 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_FOR_in_foreach185 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_RETURN_in_returnStat211 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_DEF_in_def236 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_ID_in_def240 = new BitSet(new long[]{0x0000000004000000L});
    public static final BitSet FOLLOW_ID_in_def244 = new BitSet(new long[]{0x0000000000080008L});
    public static final BitSet FOLLOW_exprRoot_in_def247 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_EXPR_in_exprRoot268 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expr_in_exprRoot270 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_set_in_expr294 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_INT_in_expr305 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_FLOAT_in_expr312 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_VAR_in_expr320 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_ID_in_expr322 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_member_in_expr332 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_unaryOp_in_expr339 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_binaryOp_in_expr346 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ternaryOp_in_expr353 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_arrayAccess_in_expr360 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_MEM_ACCESS_in_member379 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_THIS_in_member381 = new BitSet(new long[]{0x0000000004000000L});
    public static final BitSet FOLLOW_ID_in_member383 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_MEM_ACCESS_in_member395 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expr_in_member397 = new BitSet(new long[]{0x0000000004000000L});
    public static final BitSet FOLLOW_ID_in_member399 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_set_in_unaryOp424 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expr_in_unaryOp440 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_set_in_binaryOp464 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expr_in_binaryOp544 = new BitSet(new long[]{0x02EDFC7FFB5743F0L});
    public static final BitSet FOLLOW_expr_in_binaryOp548 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_COND_OP_in_ternaryOp570 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expr_in_ternaryOp574 = new BitSet(new long[]{0x02EDFC7FFB5743F0L});
    public static final BitSet FOLLOW_expr_in_ternaryOp578 = new BitSet(new long[]{0x02EDFC7FFB5743F0L});
    public static final BitSet FOLLOW_expr_in_ternaryOp582 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ARRAY_ACCESS_in_arrayAccess602 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_expr_in_arrayAccess606 = new BitSet(new long[]{0x02EDFC7FFB5743F0L});
    public static final BitSet FOLLOW_expr_in_arrayAccess610 = new BitSet(new long[]{0x0000000000000008L});

}